import { http } from "@/utils/http";
import { baseUrlApi } from "@/store/utils";
import { type DataInfo, formatToken, userKey } from "@/utils/auth";
import { storageLocal } from "@pureadmin/utils";

// 获取字典 ：从redis中获取状态常量 key Value
export const getDict = (params?: object) => {
  return http.request("get", baseUrlApi("cache/redis/query"), { params });
};

// 获取字典：从redis中获取所有字典数据 id key value..
export const getDictDetail = (params?: object) => {
  return http.request("get", baseUrlApi("cache/redis/queryDict"), { params });
};

// 上传文件
export const uploadFile = (data?: object) => {
  return http.request("post", baseUrlApi("system/file/upload"), { data });
};
export const uploadUrl = baseUrlApi("system/file/upload");

// 请求头Token
export const accessData = storageLocal().getItem<DataInfo<string>>(userKey);
export const headers = {
  Authorization: formatToken(accessData.accessToken),
  Accept: "application/json"
};
